<!doctype html>
<html>
<head>
    <title>Canvas HTML5</title>
</head>
<body>
    <canvas id="myCanvas" width="500" height="200"> 

    </canvas>
    <button id="btndraw">Draw</button>
    <script type="text/javascript">
    var _height = window.innerHeight;
    var _width = window.innerWidth;

    var myCanvas = document.getElementById("myCanvas");
    myCanvas.style.height = _height/2 + "px";
    myCanvas.style.width = _width/2 + "px";

    

    var btnDraw = document.getElementById("btndraw");
    btndraw.addEventListener("click", function() {
        var context = myCanvas.getContext("2d");

        // blue line with round ends
        context.beginPath();
        context.moveTo(10, 50);
        context.lineTo(300,50);
        context.lineWidth = 10;
        context.strokeStyle = "#00AAFF"; 
        context.lineCap = "round";
        context.stroke();

        // another line
        context.beginPath();
        context.moveTo(10, 80);
        context.lineTo(300, 80);
        context.lineWidth = 5;
        context.strokeStyle = "#FFAABB";
        context.lineCap = "butt"; // square
        context.stroke();

        // draw rect
        context.beginPath();
        context.moveTo(10, 100);
        context.fillRect(10, 100, 50, 25);
        context.strokeStyle = "#000000";
        context.stroke();

        context.beginPath();
        context.moveTo(0, 0);
        context.fillRect(25,25,50,50);
        context.clearRect(35,35,30,30);
        context.strokeRect(100,100,50,50);
    }, false);

    </script>
</body>
</html>